<!DOCTYPE html>
<html>
<head>
  <title>Show Domain - AIL</title>
	<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}">
	<!-- Core CSS -->
	<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
  <link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
  <link href="{{ url_for('static', filename='css/tags.css') }}" rel="stylesheet" type="text/css" />
	<!-- JS -->
	<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
  <script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
  <script src="{{ url_for('static', filename='js/bootstrap4.min.js') }}"></script>
	<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
	<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
  <script src="{{ url_for('static', filename='js/tags.js') }}"></script>

  <style>
    .icon_img:hover{
  		cursor: pointer;
  		color: #17a2b8;
  	}
    .icon_selected{
  		color: #007bff;
  	}
  </style>

</head>
<body>

	{% include 'nav_bar.html' %}

	<div class="container-fluid">
		<div class="row">

			{% include 'crawler/menu_sidebar.html' %}

			<div class="col-12 col-lg-10" id="core_content">

				<div class="row">

					<div class="col-12 col-xl-6">
						<div class="card mt-2">
							<div class="card-header bg-dark">
								<span class="badge badge-pill badge-light flex-row-reverse float-right">
									{% if dict_domain["status"] %}
										<div style="color:Green;">
											<i class="fas fa-check-circle fa-2x"></i>
											UP
										</div>
									{% else %}
										<div style="color:Red;">
											<i class="fas fa-times-circle fa-2x"></i>
											DOWN
										</div>
									{% endif %}
								</span>
								<h3 class="card-title text-white">{{ dict_domain['domain'] }}</h3>
							</div>
							<div class="card-body">
								<table class="table table-responsive table-condensed">
									<thead>
										<tr>
											<th>First Seen</th>
											<th>Last Check</th>
                                            <th>Languages</th>
										</tr>
									</thead>
                                    <tbody>
										<tr>
											<td class="panelText">{%if "first_seen" in dict_domain%}{{ dict_domain['first_seen'] }}{%endif%}</td>
											<td class="panelText">{%if "last_check" in dict_domain%}{{ dict_domain['last_check'] }}{%endif%}</td>
                                            <td class="panelText">
                                                {% for languages in dict_domain['languages'] %}
                                                    {{languages}}
                                                {%  endfor %}
                                            </td>
										</tr>
									</tbody>
								</table>

								<div>
                                    {% include 'modals/edit_tag.html' %}
									{% for tag in dict_domain['tags'] %}
                                        <button class="btn btn-{{ bootstrap_label[loop.index0 % 5] }}" data-toggle="modal" data-target="#edit_tags_modal" data-tagid="{{ tag }}" data-objtype="domain" data-objsubtype="" data-objid="{{ dict_domain['domain'] }}">
                                            {{ tag }}
                                        </button>
									{%  endfor %}
									<br>
                                    {% include 'modals/add_tags.html' %}
                                    <button type="button" class="btn btn-light" data-toggle="modal" data-target="#add_tags_modal">
                                        <i class="far fa-plus-square"></i>
                                    </button>
								</div>

                <table class="table table-sm table-responsive">
                  <thead>
                    <tr>
                        <td></td>
                        <td>Last Origin:</td>
                    </tr>
                  </thead>
                  <tbody>
                    {% if 'last_origin' in dict_domain %}
                      {% if dict_domain['last_origin']['item']=='manual' or dict_domain['last_origin']['item']=='auto' %}
                        <tr>
                          <td></td>
                          <td><span class="badge badge-dark">{{ dict_domain['last_origin']['item'] }}</span></td>
                        </tr>
                      {%else%}
                        <tr>
                          <td><i class="far fa-file"></i></td>
                          <td>
                            <a class="badge" target="_blank" href="{{ url_for('objects_item.showItem', id=dict_domain['last_origin']['item']) }}">{{ dict_domain['last_origin']['item'] }}</a>
                          </td>
                        </tr>
                        {% if dict_domain['last_origin']['domain'] %}
                          <td><i class="fab fa-html5"></i></td>
                          <td>
                            <a class="badge" target="_blank" href="{{ url_for('crawler_splash.showDomain', domain=dict_domain['last_origin']['domain']) }}">{{ dict_domain['last_origin']['domain']}}</a>
                          </td>
                        {%endif%}
                      <p>
                      {%endif%}
                    {%endif%}
                  </tbody>
                </table>

                <div class="d-flex flex-row-reverse bd-highlight mt-2">
                  {% if 'correlation_nb' in dict_domain %}
                      <hr>
                      <div>
                          <a href="{{ url_for('correlation.show_correlation')}}?type=domain&id={{ dict_domain['domain'] }}&correlation_objects=domain" target="_blank" style="font-size: 15px">
                              <button class="btn btn-info"><i class="fas fa-search"></i> Show Domain Correlations &nbsp;
                                  <span class="badge badge-warning">{{dict_domain['correlation_nb']}}</span>
                              </button>
                          </a>
                      </div>
                  {%endif%}
                  {% with obj_type='domain', obj_id=dict_domain['domain'], obj_subtype=''%}
                    {% include 'modals/investigations_register_obj.html' %}
                  {% endwith %}
                  <div class="mr-2">
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#investigations_register_obj_modal">
                      <i class="fas fa-microscope"></i> Investigations
                    </button>
                  </div>

                </div>

                <div class="mt-2">
                    {% with obj_type='domain', obj_id=dict_domain['domain'], obj_lvl=0%}
                        {% include 'import_export/block_add_user_object_to_export.html' %}
                    {% endwith %}
                </div>
                </div>
						</div>

            {% for obj_type in dict_domain['correlations_nb'] %}
                {% if dict_domain['correlations_nb'][obj_type] %}
                    {% if obj_type not in ['cryptocurrency', 'decoded', 'pgp', 'screenshot', 'title'] %}
                        <div class="row">
                            <div class="col-8">
                                {{ obj_type }}
                            </div>
                            <div class="col-4">
                                <span class="badge badge-primary">{{ dict_domain['correlations_nb'][obj_type] }}</span>
                            </div>
                        </div>
                    {% endif %}
                {% endif %}
            {% endfor %}

            {% if 'decoded' in dict_domain%}
              <div id="accordiondecoded" class="mt-3">
                <div class="card">
                  <div class="card-header" id="headingDecoded">
                    <div class="row">
                      <div class="col-11">
                        <div class="mt-2">
                          <i class="fas fa-lock-open"></i> Decoded&nbsp;&nbsp;
                          <div class="badge badge-warning">{{dict_domain['decoded']|length}}</div>
                        </div>
                      </div>
                      <div class="col-1">
                        <button class="btn btn-link collapsed rotate" data-toggle="collapse" data-target="#collapseDecoded" aria-expanded="false" aria-controls="collapseDecoded">
                          <i class="fas fa-chevron-circle-down"></i>
                        </button>
                      </div>
                    </div>
                  </div>
                  <div id="collapseDecoded" class="collapse" aria-labelledby="headingDecoded" data-parent="#accordiondecoded">
                    <div class="card-body">
                      <table id="tabledecoded" class="table table-striped">
                        <thead class="thead-dark">
                          <tr>
                           <th>Decoded</th>
                          </tr>
                         </thead>
                        <tbody>
                          {% for decoded in dict_domain['decoded']%}
                            <tr>
                              <td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=decoded&id={{ decoded[1] }}">{{ decoded[1] }}</a></td>
                            </tr>
                          {% endfor %}
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            {% endif %}

            {% if dict_domain['pgp']%}
              <div id="accordionpgp" class="mt-3">
                <div class="card">
                  <div class="card-header" id="headingPgp">
                    <div class="row">
                      <div class="col-11">
                        <div class="mt-2">
                          <i class="fas fa-key"></i> PGP Dumps&nbsp;&nbsp;
                          <div class="badge badge-warning">{{dict_domain['pgp']|length}}</div>
                        </div>
                      </div>
                      <div class="col-1">
                        <button class="btn btn-link collapsed rotate" data-toggle="collapse" data-target="#collapsePgp" aria-expanded="false" aria-controls="collapsePgp">
                          <i class="fas fa-chevron-circle-down"></i>
                        </button>
                      </div>
                    </div>
                  </div>
                  <div id="collapsePgp" class="collapse" aria-labelledby="headingPgp" data-parent="#accordionpgp">
                    <div class="card-body">
                      <table id="tablepgp" class="table table-striped">
                        <thead class="thead-dark">
                          <tr>
                           <th>PGP Type</th>
                           <th>Key ID</th>
                          </tr>
                         </thead>
                        <tbody>
                        {% for row in dict_domain['pgp']%}
                            {% if row[0] != "mail" %}
                                {% set var_icon = "fas fa-at" %}
                            {% elif row[0]=="name" %}
                                {% set var_icon = "fas fa-user-tag" %}
                            {% else %}
                                {% set var_icon = "fas fa-key" %}
                            {% endif %}
                            <tr>
                                <td>
                                    <i class="{{ var_icon }}"></i>&nbsp;&nbsp;{{ row[0] }}
                                </td>
                                  <td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=pgp&subtype={{ row[0] }}&id={{ row[1] }}">{{ row[1] }}</a></td>
                            </tr>
                        {% endfor %}
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            {% endif %}

            {% if dict_domain['cryptocurrency']%}
              <div id="accordioncurrency" class="mt-3">
                <div class="card">
                  <div class="card-header" id="headingcurrency">
                    <div class="row">
                      <div class="col-11">
                        <div class="mt-2">
                          <i class="fas fa-coins"></i> Cryptocurrencies&nbsp;&nbsp;
                          <div class="badge badge-warning">{{dict_domain['cryptocurrency']|length}}</div>
                        </div>
                      </div>
                      <div class="col-1">
                        <button class="btn btn-link collapsed rotate" data-toggle="collapse" data-target="#collapsecurrency" aria-expanded="false" aria-controls="collapsecurrency">
                          <i class="fas fa-chevron-circle-down"></i>
                        </button>
                      </div>
                    </div>
                  </div>
                  <div id="collapsecurrency" class="collapse" aria-labelledby="headingcurrency" data-parent="#accordioncurrency">
                    <div class="card-body">
                      <table id="tablecurrency" class="table table-striped">
                        <thead class="thead-dark">
                          <tr>
                           <th>Currency</th>
                           <th>address</th>
                          </tr>
                         </thead>
                        <tbody>
                        {% for row in dict_domain['cryptocurrency']%}
                            {% if dict_key=="bitcoin" %}
                                {% set var_icon = "fab fa-bitcoin" %}
                            {% elif dict_key=="monero" %}
                                {% set var_icon = "fab fa-monero" %}
                            {% else %}
                                {% set var_icon = "fas fa-coins" %}
                            {% endif %}
                            <tr>
                                <td>
                                    <i class="{{ var_icon }}"></i>&nbsp;&nbsp;{{ row[0] }}
                                </td>
                                <td>
                                    <a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=cryptocurrency&subtype={{ row[0] }}&id={{ row[1] }}">{{ row[1] }}</a>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            {% endif %}


            {% if dict_domain['screenshot']%}
              <div id="accordionscreenshot" class="mt-3">
                <div class="card">
                  <div class="card-header" id="headingScreenshot">
                    <div class="row">
                      <div class="col-11">
                        <div class="mt-2">
                          <i class="far fa-image"></i> Screenshot&nbsp;&nbsp;
                          <div class="badge badge-warning">{{dict_domain['screenshot']|length}}</div>
                        </div>
                      </div>
                      <div class="col-1">
                        <button class="btn btn-link collapsed rotate" data-toggle="collapse" data-target="#collapseScreenshot" aria-expanded="false" aria-controls="collapseScreenshot">
                          <i class="fas fa-chevron-circle-down"></i>
                        </button>
                      </div>
                    </div>
                  </div>
                  <div id="collapseScreenshot" class="collapse" aria-labelledby="headingScreenshot" data-parent="#accordionscreenshot">
                    <div class="card-body">
                      <table id="tablescreenshot" class="table table-striped">
                        <thead class="thead-dark">
                          <tr>
                           <th>Screenshot</th>
                          </tr>
                         </thead>
                        <tbody>
                          {% for row in dict_domain['screenshot']%}
                            <tr>
                              <td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=screenshot&id={{ row[1] }}">{{ row[1] }}</a></td>
                            </tr>
                          {% endfor %}
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            {% endif %}

            {% if 'title' in dict_domain%}
              <div id="accordiontitle" class="mt-3">
                <div class="card">
                  <div class="card-header" id="headingtitle">
                    <div class="row">
                      <div class="col-11">
                        <div class="mt-2">
                          <i class="fas fa-heading"></i> Titles&nbsp;&nbsp;
                          <div class="badge badge-warning">{{dict_domain['title']|length}}</div>
                        </div>
                      </div>
                      <div class="col-1">
                        <button class="btn btn-link collapsed rotate" data-toggle="collapse" data-target="#collapsetitle" aria-expanded="false" aria-controls="collapsetitle">
                          <i class="fas fa-chevron-circle-down"></i>
                        </button>
                      </div>
                    </div>
                  </div>
                  <div id="collapsetitle" class="collapse" aria-labelledby="headingtitle" data-parent="#accordiontitle">
                    <div class="card-body">
                      <table id="tabletitle" class="table table-striped">
                        <thead class="thead-dark">
                          <tr>
                           <th>Title</th>
                          </tr>
                         </thead>
                        <tbody>
                          {% for title in dict_domain['title']%}
                            <tr>
                              <td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=title&id={{ title['id'] }}">{{ title['content'] }}</a></td>
                            </tr>
                          {% endfor %}
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            {% endif %}

            {% if dict_domain["history"] %}
                <hr class="my-4">
                <div class="card mb-1">
                    <div class="card-header">
                        <div class="flex-row-reverse float-right text-secondary">Date:
                            <span class="badge badge-pill badge-info mt-1">
                                {{dict_domain["date"]}}
                            </span>
                        </div>
                        <h5>Capture {% if not dict_domain["crawler_history_items"] %}: Domain DOWN{% endif %}</h5>
                    </div>
                </div>

            {% if dict_domain["crawler_history_items"] %}
                <table class="table table-striped table-bordered table-hover" style="word-break: break-all;" id="myTable_1">
                    <thead class="thead-dark">
                        <tr>
                            <th>Urls</th>
                            <th class="text-center"><i class="fas fa-images"></i></th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for item in dict_domain["crawler_history_items"] %}
                            <tr>
                                <td>
                                    <a target="_blank" href="{{ url_for('objects_item.showItem') }}?id={{item["id"]}}" class="text-secondary">
                                        <div style="line-height:0.9;">{{ item['crawler']["url"] }}</div>
                                    </a>
                                    <div>
                                      {% for tag in item["tags"] %}
                                          {% if tag != 'infoleak:submission="crawler"' %}
                                              <a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
                                                <small class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</small>
                                              </a>
                                          {% endif %}
                                      {%  endfor %}
                                    </div>
                                </td>
                                {%if item['crawler']["screenshot"]%}
                                    <td class="text-center icon_img" title="Show Screenshot" onclick="reload_image('{{ item['crawler']["screenshot"] }}', '{{ item['crawler']["url"] }}', '{{ item["id"] }}');" id="{{ item['crawler']["screenshot"].replace('/', '') }}">
                                        <span class="">
                                            <i class="far fa-image"></i>
                                        </span>
                                    </td>
                                {% else %}
                                    <td></td>
                                {%endif%}

                            </tr>
                        {%  endfor %}

                    </tbody>
                </table>

                <div class="text-center mb-4">
                  <a href="{{ url_for('crawler_splash.crawlers_domain_download') }}?domain={{dict_domain['domain']}}{% if dict_domain['epoch'] %}&epoch={{dict_domain['epoch']}}{% endif %}" target="blank" style="font-size: 15px">
                      <button class="btn btn-info"><i class="fas fa-download"></i> Download Domain Content</button>
                  </a>
                </div>
              {%endif%}
						{%endif%}

            {% if dict_domain["history"] %}
                <table class="table table-hover mt-2" id="myTable_2">
                    <thead>
                    <tr>
                        <th><i class="fas fa-history"></i> Domain History</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for dom_history in dict_domain["history"] %}
                        <tr>
                            <td class="{% if dom_history["epoch"]==dict_domain["epoch"] %}text-dark table-info{% endif %}">
                                <a href="{{ url_for('crawler_splash.showDomain') }}?domain={{dict_domain["domain"]}}&epoch={{dom_history["epoch"]}}" class="text-secondary">
                                    <div class="d-flex justify-content-around" style="line-height:0.9;">
                                        <div>{{dict_domain["domain"]}}</div>
                                        {% if dom_history["status"] %}
                                            <div style="color:Green;"><i class="fas fa-check-circle"></i> UP</div>
                                        {% else %}
                                            <div style="color:Red;"><i class="fas fa-times-circle"></i>	DOWN</div>
                                        {% endif %}
                                            <div>{{ dom_history["date"] }}</div>
                                    </div>
                                </a>
                        </tr>
                    {%  endfor %}
                    </tbody>
                </table>
            {%endif%}

            {% with ollama_description=dict_domain['description'], domain_id=dict_domain['domain'] %}
                {% include 'block_domain_ollama.html' %}
            {% endwith %}

                </div>

					<div class="col-12 col-xl-6">
{#            button usafe if not tag safe          <i class="fas fa-exclamation-triangle"></i>                      #}

						<div class="mt-2">
                            {% include 'objects/image/block_blur_img_slider.html' %}
                        </div>
                        <span><img class="object_image mb-1" style="width: 100%;" alt="" id="domain_screenshot"></span>
						<div class="text-center">
							<small class="text-info" style="line-height:0.9;">
								<a target="_blank" href="" id="screenshot_link"></a>
							</small>
						</div>
					</div>

				</div>
			</div>
		</div>
	</div>

</body>


<script>
	var table;
  $(document).ready(function(){
    {% if 'decoded' in dict_domain%}
      $('#tabledecoded').DataTable();
    {% endif %}
    {% if 'screenshot' in dict_domain%}
      $('#tablescreenshot').DataTable();
    {% endif %}
    {% if 'pgp' in dict_domain%}
      $('#tablepgp').DataTable();
    {% endif %}
    {% if 'cryptocurrency' in dict_domain%}
      $('#tablecurrency').DataTable({});
    {% endif %}
    {% if 'title' in dict_domain%}
      $('#tabletitle').DataTable({});
    {% endif %}
  	table = $('#myTable_1').DataTable(
  	{
  		//"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
  		//"iDisplayLength": 5,
  		//"order": [[ 0, "desc" ]]
  	});
  });

function toggle_sidebar(){
	if($('#nav_menu').is(':visible')){
		$('#nav_menu').hide();
		$('#side_menu').removeClass('border-right')
		$('#side_menu').removeClass('col-lg-2')
		$('#core_content').removeClass('col-lg-10')
	}else{
		$('#nav_menu').show();
		$('#side_menu').addClass('border-right')
		$('#side_menu').addClass('col-lg-2')
		$('#core_content').addClass('col-lg-10')
	}
}
</script>

<script>
{% if not dict_domain['tags_safe'] %}
    blur_unsafe();
{% else %}
    blur_images();
{% endif %}



const base_url = "{{ url_for('objects_item.screenshot', filename="") }}";
const screenshot_href = "{{ url_for('objects_item.showItem') }}?id=";
const domain_screenshot = document.getElementById('domain_screenshot');
var screenshot;
var screenshot_link = $("#screenshot_link");

domain_screenshot.addEventListener('error', function() {
    domain_screenshot.src = "{{ url_for('static', filename='image/AIL.png') }}";
});

{% if "crawler_history_items" in dict_domain %}
    {% if "random_item" in dict_domain %}
        {% if dict_domain['random_item']['crawler']['screenshot'] %}
            screenshot = "{{dict_domain['random_item']['crawler']['screenshot']}}";
            var selected_icon = $("#"+screenshot.replace(/\//g, ""));
            selected_icon.addClass("icon_selected");
            selected_icon.removeClass("icon_img");

            screenshot_link.attr("href", screenshot_href + "{{dict_domain['random_item']['id']}}");
            screenshot_link.text("{{dict_domain['random_item']['crawler']['url']}}");
        {% else %}
            screenshot = "";
        {% endif %}
    {% endif %}
{% else %}
    screenshot = "";
{% endif %}
domain_screenshot.src = base_url + screenshot;

function reload_image(new_screenshot, link, item_id) {
    if (screenshot) {
        $("#"+screenshot.replace(/\//g, "")).removeClass("icon_selected").addClass("icon_img");
    }
    screenshot = new_screenshot;

    domain_screenshot.src=base_url + screenshot;
    selected_icon = $("#"+screenshot.replace(/\//g, ""));
    selected_icon.addClass("icon_selected");
    selected_icon.removeClass("icon_img")

    screenshot_link.attr("href", screenshot_href + item_id);
    screenshot_link.text(link);
}

</script>

</html>
